package com.woniuxy.income.web.controller;


import com.woniuxy.core.model.Result;
import com.woniuxy.core.util.JwtUtil;
import com.woniuxy.core.util.RedisUtil;
import com.woniuxy.income.service.CentifiedIncomeService;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 凌玉春
 * @since 2024年01月15日
 */
@RestController
@RequestMapping("/centifiedIncome")
public class CentifiedIncomeController {
    @Autowired
    private CentifiedIncomeService centifiedIncomeService;
    @Autowired
    private RedisUtil redisUtil;
    @ApiOperation("物业查看今日营业收入")
    @GetMapping("/cerGetTodayInCome")
    public Result<String> cerGetTodayInCome(@RequestHeader String token){
        Claims claims = JwtUtil.parseAdminToken(token);
        Integer certifiedInfoId =(Integer) claims.get("certifiedInfoId");
        String inCome=centifiedIncomeService.cerGetTodayInCome(certifiedInfoId);
        return Result.getResult(String.class).setMessage("物业查看今日营业收入成功").setData(inCome);
    }

    @ApiOperation("物业查看本月营业收入")
    @GetMapping("/cerGetMonthInCome")
    public Result<String> cerGetMonthInCome(@RequestHeader String token){
        Claims claims = JwtUtil.parseAdminToken(token);
        Integer certifiedInfoId =(Integer) claims.get("certifiedInfoId");
        String inCome=centifiedIncomeService.cerGetMonthInCome(certifiedInfoId);
        return Result.getResult(String.class).setMessage("物业查看本月营业收入成功").setData(inCome);
    }


}

